package com.example.gulimallserch.controller;

import com.example.gulimallserch.service.AddService;
import com.wu.common.es.SkuEsModel;
import com.wu.common.exception.BizCodeEnum;
import com.wu.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("product/spuinfo")
public class AddController {

    @Autowired
    private AddService addService;


    @PostMapping("/productStatusUp")
    public R productStatusUp(@RequestBody List<SkuEsModel> collect){
        boolean b = false;
        try {
            b = addService.productStatusUp(collect);
        }catch (Exception e){
            return R.error(BizCodeEnum.PRODUCT_UP_EXCEPTION.getCode() ,BizCodeEnum.PRODUCT_UP_EXCEPTION.getMessage());
        }
        if (b){
            return R.ok();
        }
        return R.error();
    }
}
